package com.zzty.serviceimpl;

import com.zzty.dao.GroupDao;
import com.zzty.dao.UserDao;
import com.zzty.daoimpl.GroupDaoImpl;
import com.zzty.daoimpl.UserDaoImpl;
import com.zzty.entity.Group;
import com.zzty.entity.User;
import com.zzty.service.GroupService;

import java.util.List;

public class GroupServiceImpl implements GroupService {
    UserDao ud=new UserDaoImpl();
    GroupDao gd=new GroupDaoImpl();
    public List getUsers() {
        List<User> users=null;
        try {
            users=ud.searchStudents();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return users;

    }
    public boolean insert(Group group){
        boolean result=false;
        result=gd.insert(group);
        return result;
    }
    public Integer checkGrouped(String userName){
        Integer count=0;
        count=gd.checkGrouped(userName);
        return  count;
    }
    public Integer getIdByUserName(String userName){
        Integer id=null;
        if(gd.getIdByUserName(userName)!=null) {
            id = gd.getIdByUserName(userName);
        }
        return  id;
    }
    public String getUserNamesByUserName(String userName){
        String userNames=null;
        if(gd.getUserNamesByUserName(userName)!=null){
            userNames=gd.getUserNamesByUserName(userName);
        }
        return userNames;
    }
    public String getName1ById(Integer id){
        String name1=gd.getName1ById(id);
        return name1;
    }
    public String getName2ById(Integer id){
        String name2=gd.getName2ById(id);
        return name2;
    }
    public List getGroups(){
        List<Group> groups=gd.getGroups();
        return groups;
    }
    public boolean deletes(Integer groupId){
        boolean result=gd.deletes(groupId);
        return result;
    }

}
